package com.example.springaop.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-03-11
 * Time: 22:33
 */

@Controller
@RequestMapping("user")
public class UserController {

    @RequestMapping("sayhi")
    @ResponseBody
    public String sayhi(){
        System.out.println("执行了 sayhi 方法");
//        测试抛出异常后的通知
//        int a=10/0;
        return "hi";
    }

    @RequestMapping("sayhello")
    @ResponseBody
    public String sayhello() throws InterruptedException {
//        为了让统计方法执行时间的通知 效果更明显一点, 让线程睡眠一会儿
        Thread.sleep(200);
        System.out.println("执行了 sayhello 方法");
        return "hello";
    }
}
